home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / r!scs.tut.for.nitrus.crackme.txt < prev    next >
Encoding:
Text File  |  1999-07-12  |  9.8 KB  |  260 lines

  1. Program: Nitrus Crackme -- Serial & Sound Nag (VB6)
  2. cracker: r!sc :)
  3.  
  4. layout: Ripping a Key, Finding the Keygen Routine, Patching the Sound Nag
  5.  
  6. When: 11th July '99
  7.  
  8. IMPORTANT: Make sure you have exports for VB6 loaded into SoftICE, if not,
  9. load Symbol Loader click 'File/Load Exports' and select MSVBVM60.DLL,
  10. otherwise, you wont get any breakpoints to work.. :-(
  11.  
  12.  
  13. +++++++++++++++++
  14. +Ripping a Key..+
  15. +++++++++++++++++
  16.  
  17. its programed in visual basic, so i/we try the normal bpx for serial fishing
  18.  
  19. :bpx __vbastrcmp
  20.  
  21. then i enter my name & fake serial 'Name:R!SC' / 'Serial:12121212'
  22. click on the missing register button..
  23.  
  24. Break due to BPX MSVBVM60!__vbaStrCmp
  25.  
  26. :dd esp l 10     <-- show me the last values push onto the stack
  27. 0167:0066F2F8 00402B33  004404F0  00440524  0066F41C      3+@...D.$.D...f.
  28.  RVA of esp   ret addr  lpstring  lpstring  not ours
  29.  
  30. okay, the fisrt DD is the return address, automatically pushed onto the stack
  31. when a call is executen, then the next two are pointers to the two strings to
  32. compare, so lets take a look at these..
  33.  
  34. :d 4404f0 l 20
  35. 0167:004404F0 00460035  00360037  00350038  00420037      5.F.7.6.8.5.7.B.
  36. 0167:00440500 00360034  00340036  00380032  00350036      4.6.6.4.2.8.6.5.
  37. :d 440524 l 20
  38. 0167:00440524 00650053  00690072  006C0061  0031003A      S.e.r.i.a.l.:.1.
  39. 0167:00440534 00310032  00310032  00310032  00000032      2.1.2.1.2.1.2...
  40.  
  41. hehe, one looks like our serial, the other one looks like our fake serial, but
  42. with the text 'Serial:' accidentally included.. damn.. so i exit softice, and
  43. delete 'Name:' & 'Serial:' and try again.. WHAT? it doesnt break..hmm
  44. i change my name, to 'R!SC iSD' and try again, hehe, it works, must be a
  45. length check.. further experimenting, the name has to be 5 or more letters...
  46.  
  47. Break due to BPX MSVBVM60!__vbaStrCmp
  48. Break due to BPX MSVBVM60!__vbaStrCmp
  49. :d esp l 10
  50. 0167:0066F2F8 00402B33  004404F0  004404CC  0066F41C      3+@...D...D...f.
  51.                 ret     string#1  string#2
  52.  
  53. :d 4404f0 l 20
  54. 0167:004404F0 00300037  00440032  00320037  00430035      7.0.2.D.7.2.5.C.
  55. 0167:00440500 00430032  00300039  00320037  00440035      2.C.9.0.7.2.5.D.
  56. :d 4404cc l 20
  57. 0167:004404CC 00320031  00320031  00320031  00320031      1.2.1.2.1.2.1.2.
  58. 0167:004404DC 00430000  00300039  00000000  A0000034      ..C.9.0.....4...
  59.  
  60. okay, we got a code? try it..name 'R!SC iSD' serial '702D725C2C90725D'....
  61. hehe, it works.. Registered.. cool..
  62.  
  63. experiment with some other names, seems the bigger the name, the bigger the
  64. serial, lets dig deeper and see how it makes our serial ?
  65.  
  66.  
  67. ++++++++++++++++++++++++++++++
  68. +Finding the Keygen Routine..+
  69. ++++++++++++++++++++++++++++++
  70.  
  71. okay, still with bpx __vbastrcmp, click register..hit F11 for return to caller,
  72. see where abouts we are in the 'exe...
  73.  
  74. Break due to G
  75. :u eip l 10
  76. 015F:00402B33  8BF0                MOV     ESI,EAX
  77. 015F:00402B35  8D4DD4              LEA     ECX,[EBP-2C]
  78. 015F:00402B38  F7DE                NEG     ESI
  79. 015F:00402B3A  1BF6                SBB     ESI,ESI
  80. 015F:00402B3C  46                  INC     ESI
  81. 015F:00402B3D  F7DE                NEG     ESI
  82. 015F:00402B3F  FF15CC104000        CALL    [MSVBVM60!__vbaFreeStr]
  83.  
  84. blah blah blah, lets wdasm it and take a look at this address...scroll up, lets
  85. look at the code before the compare routine, see what we can bpx on to make it
  86. break a bit earlier...
  87.  
  88. you should find this code..
  89.  
  90. * Reference To: MSVBVM60.rtcMidCharBstr, Ord:0277h
  91.                                   |
  92. :0040293E FF1548104000            Call dword ptr [00401048]
  93. :00402944 8BD0                    mov edx, eax
  94. :00402946 8D4DD0                  lea ecx, dword ptr [ebp-30]
  95. :00402949 FFD3                    call ebx
  96. :0040294B 50                      push eax
  97.  
  98. * Reference To: MSVBVM60.rtcAnsiValueBstr, Ord:0204h
  99.                                   |
  100. :0040294C FF1520104000            Call dword ptr [00401020]
  101. :00402952 666BC00B                imul ax, 000B
  102. :00402956 8B55CC                  mov edx, dword ptr [ebp-34]
  103. :00402959 0F80E2020000            jo 00402C41
  104. :0040295F 52                      push edx
  105. :00402960 0FBFF0                  movsx esi, ax
  106.  
  107. * Reference To: MSVBVM60.__vbaLenBstr, Ord:0000h
  108.                                   |
  109. :00402963 FF150C104000            Call dword ptr [0040100C]
  110. :00402969 8BC8                    mov ecx, eax
  111. :0040296B 8BC6                    mov eax, esi
  112. :0040296D 99                      cdq
  113. :0040296E F7F9                    idiv ecx
  114. :00402970 8D559C                  lea edx, dword ptr [ebp-64]
  115. :00402973 C7459C03000000          mov [ebp-64], 00000003
  116. :0040297A 52                      push edx
  117. :0040297B 8945A4                  mov dword ptr [ebp-5C], eax
  118. :0040297E 8D458C                  lea eax, dword ptr [ebp-74]
  119. :00402981 50                      push eax
  120.  
  121. * Reference To: MSVBVM60.rtcHexVarFromVar, Ord:023Dh
  122.                                   |
  123. :00402982 FF1598104000            Call dword ptr [00401098]
  124.  
  125. through another project i'm doing, reversing VB for Dummies, i know about a few
  126. of these procedures
  127.  
  128. rtcMidCharBstr --  gets a letter from a string
  129. rtcAnsiValueBstr - returns in EAX the value of this letter
  130. __vbaLenBstr ----- returns in EAX the length of a string
  131.  
  132. hehe, pretty normal serial gen routines.. lets set a bpx on rtcMidCharBstr &
  133. trace from there with F10..
  134.  
  135. :bpx rtcmidcharbstr
  136. Break due to BPX MSVBVM60!rtcMidCharBstr    (then hit F11)
  137. Break due to G
  138. :d eax l 10
  139. 0167:00540FEC 00000052  00000000  00000000  00540FE4      R.............T.
  140.  
  141. the first letter from the name?
  142. trace over 'rtcAnsiValueBstr'
  143.  
  144. :?eax
  145. 00000052  0000000082  "R"
  146.  
  147. got the ascii value of the letter in EAX now..
  148. next instruction is 'imul ax, 000B' eax=eax*11
  149.  
  150. :?eax
  151. 00000386  0000000902  "å"
  152.  
  153. keep tracing, '__vbaLenBstr' returns 8 in eax, 'R!SC iSD' is 8 characters...
  154.  
  155. :?eax
  156. 00000008  0000000008  ""
  157.  
  158. it then moves the length into ecx, gets the letter*11 back into eax..
  159. and then 'idiv ecx' , letter*11/len ?
  160.  
  161. :?eax
  162. 00000070  0000000112  "p"
  163.  
  164. 70 happens to be the first value in my serial...
  165. hit F5, then trace again, see if it gets the right answer for the next letter
  166.  
  167. Break due to BPX MSVBVM60!rtcMidCharBstr
  168. Break due to G
  169. :d eax l 10
  170. 0167:00540FEC 00000021  00000000  00000000  00540FE4      !.............T.
  171. :?eax
  172. 00000021  0000000033  "!"   <--rtcAnsiValueBstr
  173. :?eax
  174. 0000016B  0000000363  "k"  <-- imul eax,0B
  175. :?eax
  176. 0000002D  0000000045  "-"   <-- idiv ecx
  177.  
  178. yep, looks right, 702D....
  179.  
  180.  
  181. * Reference To: MSVBVM60.rtcMidCharBstr, Ord:0277h
  182.                                   |
  183. :0040293E FF1548104000            Call dword ptr [00401048]     <-- gets a char from our name
  184. :00402944 8BD0                    mov edx, eax
  185. :00402946 8D4DD0                  lea ecx, dword ptr [ebp-30]
  186. :00402949 FFD3                    call ebx
  187. :0040294B 50                      push eax
  188.  
  189. * Reference To: MSVBVM60.rtcAnsiValueBstr, Ord:0204h
  190.                                   |
  191. :0040294C FF1520104000            Call dword ptr [00401020]     <-- returns ascii value in EAX
  192. :00402952 666BC00B                imul ax, 000B                 <-- multiply it with 11 decimal
  193. :00402956 8B55CC                  mov edx, dword ptr [ebp-34]
  194. :00402959 0F80E2020000            jo 00402C41                   <-- jo to overflow routine.. ignore
  195. :0040295F 52                      push edx
  196. :00402960 0FBFF0                  movsx esi, ax                 <-- save letter*11 in si
  197.  
  198. * Reference To: MSVBVM60.__vbaLenBstr, Ord:0000h
  199.                                   |
  200. :00402963 FF150C104000            Call dword ptr [0040100C]     <-- get length in eax
  201. :00402969 8BC8                    mov ecx, eax                  <-- move length into eax
  202. :0040296B 8BC6                    mov eax, esi                  <-- copy letter*11 back to EAX
  203. :0040296D 99                      cdq                           <-- convert double to quad (clears edx..)
  204. :0040296E F7F9                    idiv ecx                      <-- divide eax by whatever
  205. :00402970 8D559C                  lea edx, dword ptr [ebp-64]
  206. :00402973 C7459C03000000          mov [ebp-64], 00000003
  207. :0040297A 52                      push edx
  208. :0040297B 8945A4                  mov dword ptr [ebp-5C], eax
  209. :0040297E 8D458C                  lea eax, dword ptr [ebp-74]
  210. :00402981 50                      push eax
  211.  
  212. * Reference To: MSVBVM60.rtcHexVarFromVar, Ord:023Dh            <-- convert our answer to ASCii ?
  213.                                   |
  214. :00402982 FF1598104000            Call dword ptr [00401098]
  215.  
  216.  
  217. okay, we have the maths.. goes something like this..
  218.  
  219. for (i=0;i<length[name];i++) {
  220. x=name[i];
  221. x=x*11;
  222. x=x/length[name];
  223. serial[i]=x;
  224. };
  225.  
  226. i can only code in asm, so i have included serial gen routine in asm only,
  227. seperate file..
  228.  
  229.  
  230. ++++++++++++++++++++++++
  231. +Patching the Sound Nag+
  232. ++++++++++++++++++++++++
  233.  
  234. Okay, i was kinda lucky.. i thought, sound==*.wav, so i search the exe for
  235. ascii text, find where the WAV file is, and corrupt the header.. as you know,
  236. corrupt headers can seriously screw up anything, Zip files, Jpeg's, Exe's..
  237.  
  238. 00005780 52 49 46 46 32 D0 02 00 57 41 56 45 66 6D 74 20 RIFF2...WAVEfmt 
  239.  
  240. i changed it to all spaces, like this
  241.  
  242. 00005780 20 20 20 20 20 D0 02 00 20 20 20 20 20 20 20 20      ...        
  243.  
  244. ran the crackme, and sure enough, no sound nag!! and luck was on my side,
  245. as there was no crash aswell.. further experimenting, i found out i just had
  246. to change one single letter in the header..
  247.  
  248. 00005780 52 49 46 46 32 D0 02 00 57 41 56 45 66 6D 74 20 RIFF2...WAVEfmt 
  249.                                                          ^^^^^   ^^^^^^^
  250.                                                          
  251. edit any single one of the marked letters, and the sound nag goes away.. :)
  252.  
  253.  
  254. okay, hope this was helpful to you, and you know know not to be scared of VB
  255. (well, most VB, some VB is scary, but, its still fun to reverse..)
  256.  
  257. laters, love R!SC
  258.  
  259.  
  260.